
pub trait Summary {
    fn summarize(&self) -> String {
        //默认实现
        format!("（更多）{}", self.summarize_author())
    }

    fn summarize_author(&self) -> String;
}

pub struct NewsArticle {
    pub title: String,
    pub author: String,
    pub content: String,
    pub pub_date: String,
}


#[derive(Debug)]
pub struct Tweet {
    pub username: String,
    pub content: String,
    pub reply: bool,
    pub retweet: bool,
}

impl Summary for NewsArticle {
    fn summarize(&self) -> String {
        format!(
            "{},{},{},{}",
            self.title, self.author, self.pub_date, self.content
        )
    }
    fn summarize_author(&self) -> String {
        format!("@{}", self.author)
    }
}
impl Summary for Tweet {
    fn summarize_author(&self) -> String {
        format!("@{:?}", self)
    }
}
